﻿using FarmSmartSleep.Common.Domain.PM;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.ProductionManagement.EweHistoryCommands
{
    public class EweHistoryCreateHandler : IRequestHandler<EweHistoryCreateCommand, Result>
    {
        private readonly IBaseRepository<SeedMotherHistoryRecord> historyRep;

        public EweHistoryCreateHandler(IBaseRepository<SeedMotherHistoryRecord> historyRep)
        {
            this.historyRep = historyRep;
        }

        public async Task<Result> Handle(EweHistoryCreateCommand request, CancellationToken cancellationToken)
        {
            var quest = new Result() { Code = (int)CodeEnum.success }; 

            var n = await historyRep.AddRange(request.SeedMotherHistoryRecord);
            quest.Code=(int)CodeEnum.success;
            quest.Messege = "添加成功";

            return quest;
            
        }
    }
}
